import React from 'react'
import { Link } from "react-router-dom";
import { imgPre } from "../../../../request/http";
import { Empty } from "antd-mobile"

import './indexgoods.less'

export default function indexgoods(props) {
  // console.log(props);
  const { getindexgoods, n, changeN } = props;
  // console.log(getindexgoods)
  var arr = ['新人专享1', '新人专享2', '新人专享3', '新人专享4'];
  return (
    <div className='indexgoods'>
      <div className='nav'>
        {arr.map((item, index) => {
          return (
            <span key={item} className={index == n ? "active" : ""}
              onClick={() => { changeN(index) }}>{item}</span>
          )
        })}
      </div>

      {getindexgoods.length > 0 ? <div className='list'>
        {getindexgoods[n].content.map((item) => {
          return (
            <Link to={"/detail/" + item.id +'/1'} className="item" key={item.id}>
              <img src={imgPre + item.img} alt="" />
              <div>
                <p>{item.goodsname}</p>
                <p>{item.description}</p>
                <del>原价{item.market_price}</del>
                <span>现价{item.price}</span>
              </div>
            </Link>
          );
        })}
      </div>
        : <Empty description='暂无数据' />}
    </div>
  );
}

